Split talk_to_otherend into two pieces, one for getting the otherend details,
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 15 Dec 2005 18:38:49 +0000 (18:38 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 15 Dec 2005 18:38:49 +0000 (18:38 +0000)
and one for registering the watch on the otherend's path.  This means that we
get the fix intended by xen-unstable changeset 8370:39a616126104 (i.e. we only
register the watch once drv->probe() has succeeded), but without breaking block
devices.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c

index ea09e357001510b87d99a5595769c05c35adbccd..72e81712d81d61d2b91901508b72462de3e36486 100644 (file)
@@ -315,15 +315,16 @@ static void otherend_changed(struct xenbus_watch *watch,
 static int talk_to_otherend(struct xenbus_device *dev)
 {
        struct xenbus_driver *drv = to_xenbus_driver(dev->dev.driver);
-       int err;
 
        free_otherend_watch(dev);
        free_otherend_details(dev);
 
-       err = drv->read_otherend_details(dev);
-       if (err)
-               return err;
+       return drv->read_otherend_details(dev);
+}
+
 
+static int watch_otherend(struct xenbus_device *dev)
+{
        return xenbus_watch_path2(dev, dev->otherend, "state",
                                  &dev->otherend_watch, otherend_changed);
 }
@@ -349,14 +350,22 @@ static int xenbus_dev_probe(struct device *_dev)
                goto fail;
        }
 
+       err = talk_to_otherend(dev);
+       if (err) {
+               printk(KERN_WARNING
+                      "xenbus_probe: talk_to_otherend on %s failed.\n",
+                      dev->nodename);
+               return err;
+       }
+
        err = drv->probe(dev, id);
        if (err)
                goto fail;
 
-       err = talk_to_otherend(dev);
+       err = watch_otherend(dev);
        if (err) {
                printk(KERN_WARNING
-                      "xenbus_probe: talk_to_otherend on %s failed.\n",
+                      "xenbus_probe: watch_otherend on %s failed.\n",
                       dev->nodename);
                return err;
        }
@@ -826,6 +835,14 @@ static int resume_dev(struct device *dev, void *data)
                return err;
        }
 
+       err = watch_otherend(xdev);
+       if (err) {
+               printk(KERN_WARNING
+                      "xenbus_probe: resume (watch_otherend) %s failed: "
+                      "%d.\n", dev->bus_id, err);
+               return err;
+       }
+
        if (drv->resume)
                err = drv->resume(xdev);
        if (err)